/* $Id: lintf.h 7557b5d4d82b 2012/12/02 09:07:16 pgurumur $
 * Copyright (c) 2009 Prabhu Gurumurthy <pgurumur@gmail.com>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */
#ifndef  __LUA_INTF_H_
#define  __LUA_INTF_H_

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>

#include <arpa/inet.h>

#include <net/if.h>
#ifdef __linux__
#include <netpacket/packet.h>
#include <net/ethernet.h>
#include <netinet/ether.h>
#else
#include <net/if_dl.h>
#endif

#include <netinet/in.h>
#include <netinet/if_ether.h>

#include <errno.h>
#include <fcntl.h>
#include <ifaddrs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define LUA_LIB

/* lua includes */
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

/* Module specific inits */

#define  LMOD_NAME "lintf"
#define  LMOD_VERSION "Lua net interface 0.1"
#define  LMOD_COPYRIGHT "Copyright (C) 2008 Prabhu Gurumurthy"
#define  LMOD_AUTHOR "Prabhu Gurumurthy"
#define  LMOD_TYPE LMOD_NAME "handle"

#define  MAXLINE 4096

/* functions callable from lua code */
static int intf_getipv4(lua_State *);
static int intf_getipv6(lua_State *);
static int intf_getphyaddr(lua_State *);
LUALIB_API int luaopen_lintf(lua_State *);

/* The above mentioned functions, lua names */
static const luaL_reg intf_lib[] = {
   { "ipv4", intf_getipv4 },
   { "ipv6", intf_getipv6 },
   { "ether", intf_getphyaddr },
   { NULL, NULL }
};

#endif   
